//
//  PlatformIntroViewController.m
//  CYWFrame
//
//  Created by Macx on 2017/11/23.
//  Copyright © 2017年 Macx. All rights reserved.
//

#import "PlatformIntroViewController.h"
#import "PerMessageDetailsViewController.h"

@interface PlatformIntroViewController ()

@end

@implementation PlatformIntroViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self createUI];
    
}

- (void)createUI {
    
    self.navigationItem.title = @"关于平台";
    self.view.backgroundColor = UISeparatedColorRGB;
    
    
    UIView *headV = [[UIView alloc] init];
    [self.view addSubview:headV];
    headV.backgroundColor = kWhiteColor;
    
    UIImageView *logoImgV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 50, SW(4), SW(4))];
    [headV addSubview:logoImgV];
    logoImgV.image = IMAGE(@"logo");
    logoImgV.centerX = self.view.centerX;
    
    //2先获取当前工程项目版本号
    NSDictionary *infoDic=[[NSBundle mainBundle] infoDictionary];
    NSString*currentVersion=infoDic[@"CFBundleShortVersionString"];

    UILabel *v = [[UILabel alloc] initWithFrame:CGRectMake(0, logoImgV.y+logoImgV.height+10, SCREEN_WIDTH, 30)];
    [headV addSubview:v];
    v.text = [NSString stringWithFormat:@"Version %@", currentVersion];
    v.font = kUHSystemFontWithSize(15);
    v.textAlignment = NSTextAlignmentCenter;
    v.textColor = kGrayColor;
    
    headV.frame = CGRectMake(0, 0, SCREEN_WIDTH, v.y+v.height+20);
    
    UIView *midV = [[UIView alloc] init];
    //[self.view addSubview:midV];
    midV.backgroundColor = kWhiteColor;
    
    UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, SCREEN_WIDTH, [LZCTools textSizeWithText:@"字数" font:kUHSystemFontWithSize(15)].height)];
    [midV addSubview:title];
    title.text = @"";
    title.textAlignment = NSTextAlignmentCenter;
    title.font = kUHSystemFontWithSize(15);
    
    UILabel *intro = [[UILabel alloc] init];
    [midV addSubview:intro];
    intro.textColor = kGrayColor;
    intro.text = @"";
    intro.font = kUHSystemFontWithSize(13);
    intro.numberOfLines = 0;
    CGSize moodSize = [intro.text sizeWithFont:kUHSystemFontWithSize(13) constrainedToSize:CGSizeMake(SCREEN_WIDTH-20, 1000) lineBreakMode:NSLineBreakByWordWrapping];
    intro.frame = CGRectMake(10, title.y+title.height+10, SCREEN_WIDTH-20, moodSize.height);
    
    midV.frame = CGRectMake(0, headV.height+1, SCREEN_WIDTH, intro.height+intro.y+10);
    
    
    UILabel *agreement = [[UILabel alloc] init];
    [self.view addSubview:agreement];
    agreement.text = @"Copyright © 2018 星河汇";
    agreement.textAlignment = NSTextAlignmentCenter;
    agreement.font = kUHSystemFontWithSize(12);
    
    CGSize agreement2Size = [LZCTools textSizeWithText:agreement.text font:agreement.font];
    agreement.frame = CGRectMake(0, SCREEN_HEIGHT-SW(20)-agreement2Size.height-64, SCREEN_WIDTH, agreement2Size.height);
    
    UILabel *agreement2 = [[UILabel alloc] init];
    [self.view addSubview:agreement2];
    agreement2.text = @"星河汇的服务使用协议";
    agreement2.textAlignment = NSTextAlignmentCenter;
    agreement2.textColor = UIMainColorRGB;
    agreement2.font = kUHSystemFontWithSize(12);
    [agreement2 addTarget:self action:@selector(agreementClick)];

    
    agreement2.frame = CGRectMake(0, agreement.y-10-agreement2Size.height, SCREEN_WIDTH, agreement2Size.height);
    
}

/**
 点击用户协议
 */
- (void)agreementClick {
    NSLog(@"点击用户协议");
    
    PerMessageDetailsViewController *detailVC = [[PerMessageDetailsViewController alloc] init];
    detailVC.type = 1;
    
    [self.navigationController pushViewController:detailVC animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
